package com.example.demo.service;

import com.example.demo.po.GeneticTestingPackage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.xml.bind.ValidationException;

/**
 * @Description: //TODO
 * @ProjectName: demo6
 * @Package: com.example.demo.service
 * @Author: FX
 * @CreateDate: 2018/10/27 11:03
 * @Version: 1.0
 * Copyright: Copyright (c) 2018
 */
@Service
public class TestEsServiceImpl implements TestEsService {
    @Autowired
    PackageService packageService;
    @Autowired
    EsService esService;

    @Transactional(rollbackFor = {Exception.class})
    @Override
    public void addPackage(GeneticTestingPackage geneticTestingPackage){
        boolean save = packageService.save(geneticTestingPackage);
        boolean addes = esService.addes(geneticTestingPackage);
        if(save&&addes){
            System.out.println("成功");
        }else{
            System.out.println("应该抛出异常");
            throw new RuntimeException("异常");

        }
    }
}
